<template>
        <div class="app2">
            子组件2
            <h4>电脑：{{ compent }}</h4>
            <h4 v-show="toy">子组件1传来的：{{ toy }}</h4>
        </div>
</template>
    
<script setup lang='ts'>
import { ref,onUnmounted } from 'vue';
import emitter from '@/utils/emitter';

let compent = ref('联想')
let toy = ref('')
emitter.on('send-toy', (value:any) => {
    // console.log('send-toy',value);
    toy.value = value
})
onUnmounted(() => {
    emitter.off('send-toy')
})
</script>
    
<style scoped>
    .app2{
        padding: 10px;
        margin: 10px;
        background-color: orange;
        border-radius: 5px;
        box-shadow: 0 0 10px ;
    }
</style>